Show elapsed time on the workflow job output toolbar - #393
Conversation
Regular job output pages show a live hh:mm:ss elapsed badge that ticks every second while the job runs and switches to the API's final elapsed value on completion. Workflow job output pages showed no elapsed time at all, live or final. The workflow output toolbar now renders the same badge next to Total Nodes: a one-second interval recomputes elapsed from job.started while the workflow runs, and the websocket-driven job refetch (useWsJob refetches on terminal statuses) delivers finished/elapsed so the badge settles on the authoritative value without a reload. calculateElapsed moves from a private helper inside OutputToolbar to util/dates alongside secondsToHHMMSS, and OutputToolbar now uses both shared helpers; no behavior change there. Both strings already exist in the locale catalogs, so no catalog changes are needed.
There was a problem hiding this comment.
Pull request overview
This PR adds a live hh:mm:ss elapsed-time badge to the Workflow Job Output toolbar (matching the behavior of regular job output), and centralizes the elapsed-time calculation into shared date utilities.
Changes:
- Render an “Elapsed” badge in
WorkflowOutputToolbar, updating every second while the workflow job is running and switching to the API-provided finalelapsedafter completion. - Promote
calculateElapsedintoawx/ui/src/util/dates.jsand updateJobOutput’sOutputToolbarto use sharedsecondsToHHMMSS. - Add unit tests for
calculateElapsedplus workflow toolbar tests validating ticking behavior and final-value behavior.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| awx/ui/src/util/dates.js | Adds exported calculateElapsed helper alongside existing duration formatting helpers. |
| awx/ui/src/util/dates.test.js | Adds unit tests covering calculateElapsed behavior under fake timers. |
| awx/ui/src/screens/Job/WorkflowOutput/WorkflowOutputToolbar.js | Adds the elapsed-time badge and timer state/effect to the workflow output toolbar. |
| awx/ui/src/screens/Job/WorkflowOutput/WorkflowOutputToolbar.test.js | Extends toolbar tests to cover elapsed badge ticking and final elapsed display. |
| awx/ui/src/screens/Job/JobOutput/shared/OutputToolbar.js | Switches elapsed formatting to shared secondsToHHMMSS and imports shared helpers. |
| awx/ui/package-lock.json | Contains a small lockfile metadata change unrelated to the feature. |
Files not reviewed (1)
- awx/ui/package-lock.json: Generated file
| <Badge isRead id="workflow-elapsed-badge"> | ||
| {job.finished | ||
| ? secondsToHHMMSS(job.elapsed) | ||
| : activeJobElapsedTime} | ||
| </Badge> |
| shouldFind(`Button[ouiaId="edit-workflow"]`); | ||
| shouldFind('Button#workflow-output-toggle-legend'); | ||
| shouldFind('Badge'); | ||
| expect(wrapper.find('Badge')).toHaveLength(2); |
| test('Shows correct number of nodes', () => { | ||
| // The start node (id=1) and deleted nodes (isDeleted=true) should be ignored | ||
| expect(wrapper.find('Badge').text()).toBe('1'); | ||
| expect(wrapper.find('Badge').last().text()).toBe('1'); |
- When a websocket status_changed message sets job.finished before the follow-up refetch delivers the authoritative job.elapsed, keep showing the last live timer value instead of formatting undefined (applied to both toolbars; new test covers the window) - Select badges by id in tests instead of count/order - Revert accidental package-lock metadata churn
|
Otherwise tested and works fine. |
|
All four comments addressed: (1) the badge keeps showing the last live timer value while |
|
All review feedback on this PR is addressed, and after the latest merges to main (#376, #380, #386, #389, #391, #394) this branch has been re-verified: it merges cleanly into current main (51188f0) and is conflict-free against every other open PR (git merge-tree, all pairs). Ready to merge — in any order relative to #385/#390/#392/#393/#395. |
The elapsed badge sat flush against the Total Nodes label and resized as the ticking digits changed width. It now has a 20px right margin, a 70px minimum width and tabular-nums digits, so the toolbar no longer shifts as the timer runs. The job output toolbar's elapsed badge gets the same width treatment (it had the identical wobble; its spacing was already handled by BadgeGroup).
|
@cigamit good catch — and apologies, my earlier "all feedback addressed" comment was posted after yours but only covered the Copilot review items; I'd missed the conversation thread. Both points from your screenshot are fixed now:
The job output toolbar's elapsed badge got the same width treatment, since it had the identical wobble (its spacing was already fine via BadgeGroup). 132 tests pass across both toolbars; lint clean. |
922c6f3 to
b735787
Compare

SUMMARY
Regular job output pages show a live
hh:mm:sselapsed badge — ticking every second while the job runs, switching to the API's finalelapsedvalue on completion. Workflow job output pages showed no elapsed time at all, live or final.The workflow output toolbar now renders the same badge next to Total Nodes:
job.startedwhile the workflow runsuseWsJobrefetches on terminal statuses) deliversfinished/elapsed, so the badge settles on the authoritative final value without a reloadcalculateElapsedmoves from a private helper insideOutputToolbartoutil/datesalongsidesecondsToHHMMSS, andOutputToolbarnow uses both shared helpers (no behavior change there)No locale-catalog changes needed — both strings (
Elapsed,Elapsed time that the job ran) already exist in the catalogs.Independent of every other open PR — verified conflict-free via pairwise
git merge-tree(the elapsed-state hooks are deliberately placed clear of the hunks #392 touches in the same file).ISSUE TYPE
COMPONENT NAME
ASCENDER VERSION
ADDITIONAL INFORMATION
Tests: unit coverage for
calculateElapsed(zero/unstarted cases, fake-timer arithmetic) and two toolbar tests (badge ticks under fake timers while running; shows the formatted finalelapsedand stops ticking once finished).